import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/MobileLogin.vue')
  },
  {
    path: '/login2',
    name: 'login2',
    component: () => import('@/views/login/PwLogin.vue')
  }
]

let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  // if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originPush.call(this, location).catch(err => { return; })
}
// replace
VueRouter.prototype.replace = function replace(location, onResolve, onReject) {
  // if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originReplace.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
